{#
# This file is part of Zenodo.
# Copyright (C) 2016 CERN.
#
# Zenodo is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Zenodo is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Zenodo; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.
-#}

{%- extends "zenodo_records/record_detail.html" %}

{% from "invenio_userprofiles/settings/_macros.html" import render_field %}

{%- block page_body %}
<div class="container record-admin">
  <div class="row">
    <div class="col-xs-12" align="center">
      <div class="progress">
        <div class="progress-bar progress-bar-danger progress-bar-striped" role="progressbar" style="width: 100%">
          <strong>Danger Zone</strong>
      </div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-xs-12">
      <h1>Delete record</h1>
      <div class="alert alert-warning">
        <p><h4>Are you ABSOLUTELY sure?</h4> This action <strong>CANNOT</strong> be undone! Deleting a record will
        permanently delete the associated files from disk.</p>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      <div class="panel panel-default">
        <div class="panel-heading">Record and associated objects</div>
        <ul class="list-group">
          {% if owners %}
            <li class="list-group-item">
              <h5>Owners</h5>
              <table class="table table-bordered">
                <tr>
                  <th>User ID</th>
                  <th>Email</th>
                  <th>Username</th>
                  <th>Full Name</th>
                </tr>
                {%- for owner in owners %}
                <tr>
                  <td>{{owner.id}}</td>
                  <td>{{owner.email}}</td>
                  <td>{{owner.profile and owner.profile.username}}</td>
                  <td>{{owner.profile and owner.profile.full_name}}</td>
                </tr>
                {%- endfor %}
              </table>
            </li>
          {% endif %}
          <li class="list-group-item">
            <h5>UUID</h5>
            {{record.id}}, revision {{record.revision_id}} (created: {{record.created}}, updated: {{record.updated}})
          </li>
          <li class="list-group-item">
            <h5>Deposit UUID</h5>
            {{deposit.id}}, revision {{deposit.revision_id}} (created: {{deposit.created}}, updated: {{deposit.updated}})
          </li>
          <li class="list-group-item">
            <h5>Persistent identifiers</h5>
            <table class="table table-bordered">
              <tr>
                <th>PID Type</th>
                <th>PID Value</th>
                <th>Status</th>
              </tr>
              {%- for p in pids %}
              <tr>
                <td>{{p.pid_type}}</td>
                <td>{{p.pid_value}}</td>
                <td>{{p|pidstatus}}</td>
              </tr>
              {%- endfor %}
            </table>
          </li>
          <li class="list-group-item">
            <h5>Metadata</h5>
            <pre>{{record|tojson}}</pre>
          </li>
          <li class="list-group-item">
            <h5>Buckets</h5>
            <table class="table table-bordered">
              {%- if record.files %}
              <tr>
                <td colspan="4" class="info">
                  <strong>Record bucket ({{record.files.bucket}})</strong>
                </td>
              </tr>
              <tr>
                <th>Object</th>
                <th>URI</th>
                <th>Size</th>
                <th>Checksum</th>
              </tr>
              {%- for f in record.files %}
              <tr>
                <td>{{f.key}}</td>
                <td>{{f.file.uri}}</td>
                <td>{{f.file.size}}</td>
                <td>{{f.file.checksum}}</td>
              </tr>
              {%- endfor %}
              {%- endif %}
              {%- if deposit.files %}
              <tr>
                <td colspan="4" class="info">
                  <strong>Deposit bucket ({{deposit.files.bucket}})</strong>
                </td>
              </tr>
              <tr>
                <th>Object</th>
                <th>URI</th>
                <th>Size</th>
                <th>Checksum</th>
              </tr>
              {%- for f in deposit.files %}
              <tr>
                <td>{{f.key}}</td>
                <td>{{f.file.uri}}</td>
                <td>{{f.file.size}}</td>
                <td>{{f.file.checksum}}</td>
              </tr>
              {%- endfor %}
              {%- endif %}
            </table>
          </li>
        </ul>
      </div>

      <div class="panel panel-danger">
        <div class="panel-heading">Delete options</div>
        <div class="panel-body">
        <form action="" method="POST">
          {{form.csrf_token}}
          {{ render_field(form.standard_reason) }}
          {{ render_field(form.reason) }}
          <div class="row">
            <div class="col-md-6">{{ render_field(form.remove_files) }}</div>
            <div class="col-md-6">{{ render_field(form.remove_sips) }}</div>
          </div>
          {{ render_field(form.confirm) }}
          <button class="btn btn-block btn-danger" type="submit">
            <i class="fa fa-trash"></i>
            Permanently delete record
          </button>
        </form>
        </div>
      </div>
    </div>
  </div>
</div>



{%- endblock page_body %}


